{% extends 'base-layer.html' %}
{% load staticfiles %}

{% block css %}
    <link rel="stylesheet" href="{% static 'js/plugins/layer/skin/layer.css' %}">
{% endblock %}

{% block main %}
    <div class="box box-primary">
        <form class="form-horizontal" id="addForm" method="post">
            <div class="box-header ">
                <ul>
                    <li>
                    <div class="col-sm-10 text-left">{{ clause.name }}{{ clause.desc }}</div>
                    </li>
                    <li>
                         <div class="col-sm-10 text-left">  {{ ref_type }}</div>
                    </li>
                </ul>

            </div>
{#             <div class="box-header">#}
{#              <form class="form-inline" id="queryForm">#}
{#                <div class="form-group searchArea margin-r-5 margin-top-5">#}
{#                    <label>标准：</label>#}
{#                    <label>{{ clause.name }}{{ clause.desc }}</label>#}
{##}
{#                    <input type="text" name="assetNum" class="form-control inputText" id="assetNum">#}
{##}
{#                </div>#}
{#                <div class="form-group searchArea margin-r-5 margin-top-5">#}
{#                    <label>类型：</label> <label>{{ ref_type }}</label>#}
{#                    <input type="text" name="model" class="form-control inputText" id="model">#}
{#                </div>#}
{##}
{#            </form>#}
{#            </div>#}
            <div class="box-body">
                {% csrf_token %}
                <input type="hidden" name='id' value="{{ id }}"/>
                {{ form.media }}
                {{ form.desc }}
            </div>
            <div class="box-footer ">
                <div class="row span7 text-center ">
                    {#              <button type="button" id="btnCancel" class="btn btn-default margin-right " >重置</button>#}
                    <button type="button" id="btnSave" class="btn btn-info margin-right ">保存</button>
                </div>
            </div>

        </form>
    </div>

{% endblock %}

{% block javascripts %}
    <script src="{% static 'plugins/combo-select/jquery.combo.select.js' %}"></script>
    <script type="text/javascript">
        //处理CKEDITOR的值
        function CKupdate() {
            for (instance in CKEDITOR.instances)
                CKEDITOR.instances[instance].updateElement();
        }

        $("#btnSave").click(function () {
            CKupdate(); //在提交表单前需要做以上处理
            var data = $("#addForm").serialize();
            $.ajax({
                type: $("#addForm").attr('method'),
                url: "{% url 'criterion-reference' %}",
                data: data,
                cache: false,
                success: function (msg) {
                    if (msg.result) {
                        layer.alert('数据保存成功！', {icon: 1}, function (index) {
                            parent.layer.closeAll(); //关闭所有弹窗
                        });
                    } else {
                        layer.alert('数据保存失败', {icon: 5});
                        //$('errorMessage').html(msg.message)
                    }
                    return;
                }
            });
        });


        /*点取消刷新新页面*/

        $("#btnCancel").click(function () {
            window.location.reload();

        });

    </script>

{% endblock %}
